--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 053b1b0bf2880e89f5d649aa5e5677814ecdd5c9
Parents : 0022b63
Author : Mark Qvist <bc7291552be7a58f361522990465165c>
Signature : T66BB85Valid, signed by author
Date : 2026-07-26T12:31:31+02:00
Fixed negative power consumption display in object details
Changes
Diff
diff --git a/sbapp/ui/objectdetails.py b/sbapp/ui/objectdetails.py
index a4728129..e3ccb377 100644
--- a/sbapp/ui/objectdetails.py
+++ b/sbapp/ui/objectdetails.py
@@ -636,15 +636,15 @@ class RVDetails(MDRecycleView):
if cs != None:
for c in cs:
label = c["label"]; cicon = c["custom_icon"]; watts = c["w"]; prefix = ""
- if watts == 0: prefix = ""
- elif watts < 1/1e6: watts *= 1e9; prefix = "n"
- elif watts < 1/1e3: watts *= 1e6; prefix = "µ"
- elif watts < 1: watts *= 1e3; prefix = "m"
- elif watts >= 1e15: watts /= 1e15; prefix = "E"
- elif watts >= 1e12: watts /= 1e12; prefix = "T"
- elif watts >= 1e9: watts /= 1e9; prefix = "G"
- elif watts >= 1e6: watts /= 1e6; prefix = "M"
- elif watts >= 1e3: watts /= 1e3; prefix = "K"
+ if abs(watts) == 0: prefix = ""
+ elif abs(watts) < 1/1e6: watts *= 1e9; prefix = "n"
+ elif abs(watts) < 1/1e3: watts *= 1e6; prefix = "µ"
+ elif abs(watts) < 1: watts *= 1e3; prefix = "m"
+ elif abs(watts) >= 1e15: watts /= 1e15; prefix = "E"
+ elif abs(watts) >= 1e12: watts /= 1e12; prefix = "T"
+ elif abs(watts) >= 1e9: watts /= 1e9; prefix = "G"
+ elif abs(watts) >= 1e6: watts /= 1e6; prefix = "M"
+ elif abs(watts) >= 1e3: watts /= 1e3; prefix = "K"
if cicon: set_icon = cicon
else: set_icon = s["icon"]
watts = round(watts, 2)
@@ -657,15 +657,15 @@ class RVDetails(MDRecycleView):
if cs != None:
for c in cs:
label = c["label"]; cicon = c["custom_icon"]; watts = c["w"]; prefix = ""
- if watts == 0: prefix = ""
- elif watts < 1/1e6: watts *= 1e9; prefix = "n"
- elif watts < 1/1e3: watts *= 1e6; prefix = "µ"
- elif watts < 1: watts *= 1e3; prefix = "m"
- elif watts >= 1e15: watts /= 1e15; prefix = "E"
- elif watts >= 1e12: watts /= 1e12; prefix = "T"
- elif watts >= 1e9: watts /= 1e9; prefix = "G"
- elif watts >= 1e6: watts /= 1e6; prefix = "M"
- elif watts >= 1e3: watts /= 1e3; prefix = "K"
+ if abs(watts) == 0: prefix = ""
+ elif abs(watts) < 1/1e6: watts *= 1e9; prefix = "n"
+ elif abs(watts) < 1/1e3: watts *= 1e6; prefix = "µ"
+ elif abs(watts) < 1: watts *= 1e3; prefix = "m"
+ elif abs(watts) >= 1e15: watts /= 1e15; prefix = "E"
+ elif abs(watts) >= 1e12: watts /= 1e12; prefix = "T"
+ elif abs(watts) >= 1e9: watts /= 1e9; prefix = "G"
+ elif abs(watts) >= 1e6: watts /= 1e6; prefix = "M"
+ elif abs(watts) >= 1e3: watts /= 1e3; prefix = "K"
if cicon: set_icon = cicon
else: set_icon = s["icon"]
watts = round(watts, 2)
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────